﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB.Driver;

namespace mongodb
{
    public class MongoConfig
    {
        public static MongoServerSettings config = null;
        static MongoConfig()
        {
            config = MongoServerSettings.FromUrl(MongoUrl.Create(conStr));
            //最大连接池
            config.MaxConnectionPoolSize = 500;
            //最大闲置时间
            config.MaxConnectionIdleTime = TimeSpan.FromSeconds(30);
            //最大存活时间
            config.MaxConnectionLifeTime = TimeSpan.FromSeconds(60);
            //链接时间
            config.ConnectTimeout = TimeSpan.FromSeconds(10);
            //等待队列大小
            config.WaitQueueSize = 50;
            //socket超时时间
            config.SocketTimeout = TimeSpan.FromSeconds(10);
            //队列等待时间
            config.WaitQueueTimeout = TimeSpan.FromSeconds(60);
            //操作时间
            config.OperationTimeout = TimeSpan.FromSeconds(60);
        }
        public static string conStr
        {
            get
            {
                return ConfigurationManager.AppSettings["connectionString"];
            }
        }
        public static string mongoDB
        {
            get
            {
                return ConfigurationManager.AppSettings["mongoDB"];
            }
        }
    }
}
